package test.enba.nacos.provider.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import test.enba.nacos.provider.properties.DemoProperties;

@RestController
@RequestMapping("/nacos")
public class NcosController {

  private final DemoProperties nacosProperties;

  public NcosController(DemoProperties nacosProperties) {
    this.nacosProperties = nacosProperties;
  }

  @RequestMapping("/test")
  public String test() {
    return nacosProperties.getName()
        + ":"
        + nacosProperties.getAge()
        + ":"
        + nacosProperties.isFlag();
  }

  @RequestMapping(value = "/echo/{string}", method = RequestMethod.GET)
  public String echo(@PathVariable String string) {
    return "Hello Nacos Discovery " + string;
  }
}
